package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.List;

/**
 * Created by archoud on 3/5/14. nbvn
 */
public class Out {

    private PrintStream stream;

    public Out(PrintStream stream){

        this.stream = stream;

    }

    public String formatList(String header, List<?> list) {
        String result = "\n\n" + header + "\n\n";
        for (int i = 0; i < list.size(); i++) {
            String text = list.get(i).toString();

            int oneBaseIndex = i + 1;
            result += oneBaseIndex + ". " + text + "\n";
        }
        return result;
    }

    public void printList(String header, List<?> list){
        this.println(formatList(header, list));
    }


    public void println(String string) {
        this.stream.println(string);
    }
}
